{#
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at
 #
 # http://www.apache.org/licenses/LICENSE-2.0
 #
 # Unless required by applicable law or agreed to in writing, software
 # distributed under the License is distributed on an "AS IS" BASIS,
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-#}
{% if request.user %}
  <div id="user-indicator"
       class="horizontal-menu horizontal-menu--light horizontal-menu--tall">
    <nav aria-label="{% trans %}Main navigation{% endtrans %}"
         class="dropdown dropdown--on-menu dropdown--with-icons">
      <button type="button"
              class="horizontal-menu__link--with-icon horizontal-menu__link dropdown__trigger"
              aria-haspopup="true"
              aria-expanded="false"
              aria-label="{% trans %}View menu{% endtrans %}">
        <img class="user-image"
             src="{{ gravatar(request, request.user.email, size=40) }}"
             alt="User Image">
        {{ request.user.username }}
        <span class="dropdown__trigger-caret">
          <i class="fa fa-caret-down" aria-hidden="true"></i>
        </span>
      </button>
      <ul class="dropdown__content"
          aria-hidden="true"
          aria-label="{% trans %}Main menu{% endtrans %}">
        {% if request.has_permission(Permissions.AdminDashboardRead) %}
          <li>
            <a href="{{ request.route_path('admin.dashboard') }}"
               class="dropdown__link">
              <i class="fa fa-wrench" aria-hidden="true"></i>
              {% trans %}Admin{% endtrans %}
            </a>
          </li>
        {% endif %}
        <li>
          <a href="{{ request.route_path('manage.projects') }}"
             class="dropdown__link">
            <i class="fa fa-cubes" aria-hidden="true"></i>
            {% trans %}Your projects{% endtrans %}
          </a>
        </li>
        {% if request.organization_access %}
          <li>
            <a href="{{ request.route_path('manage.organizations') }}"
               class="dropdown__link">
              <i class="fa fa-sitemap" aria-hidden="true"></i>
              {% trans %}Your organizations{% endtrans %}
            </a>
          </li>
        {% endif %}
        <li>
          <a href="{{ request.route_path('manage.account') }}"
             class="dropdown__link">
            <i class="fa fa-cog" aria-hidden="true"></i>
            {% trans %}Account settings{% endtrans %}
          </a>
        </li>
        <li>
          <a href="{{ request.route_path('accounts.profile', username=request.user.username) }}"
             class="dropdown__link">
            <i class="fa fa-user-circle" aria-hidden="true"></i>
            {% trans %}Public profile{% endtrans %}
          </a>
        </li>
        <li>
          <a href="{{ request.route_path('help') }}" class="dropdown__link">
            <i class="fa fa-question-circle" aria-hidden="true"></i>
            {% trans %}Help{% endtrans %}
          </a>
        </li>
        <li>
          <a href="{{ request.route_path('sponsors') }}" class="dropdown__link">
            <i class="fa fa-heart" aria-hidden="true"></i>
            {% trans %}Sponsors{% endtrans %}
          </a>
        </li>
        <li>
          <form method="post" action="{{ request.route_path('accounts.logout') }}">
            <input name="csrf_token"
                   type="hidden"
                   value="{{ request.session.get_csrf_token() }}">
            <button type="submit" class="dropdown__link">
              <i class="fa fa-sign-out-alt" aria-hidden="true"></i>
              {% trans %}Log out{% endtrans %}
            </button>
          </form>
        </li>
      </ul>
    </nav>
  </div>
{% else %}
  {% from 'base.html' import main_navigation_logged_out with context %}
  {{ main_navigation_logged_out() }}
{% endif %}
